package handler

import (
	"context"

	"mxshop_srvs/order_srv/dao/mysql"
	"mxshop_srvs/order_srv/model"
	proto "mxshop_srvs/order_srv/proto/gen/v1"
)

type Service struct {
	OrderManager
	DB *mysql.Gorm
	OrderIDGenerator
	proto.UnimplementedOrderServiceServer
}

// NewService defines an order service.
func NewService(om OrderManager, db *mysql.Gorm, idGenerator OrderIDGenerator) *Service {
	return &Service{
		OrderManager:     om,
		DB:               db,
		OrderIDGenerator: idGenerator,
	}
}

// OrderManager defines the ACL (Anti Corruption Layer)
// for order management.
type OrderManager interface {
	OrderHandling(c context.Context, goodsIDs []int32, goodsNumsMap map[int32]int32) (int32, []*model.OrderGoods, error)
}
